package com.fyk.controller;

import com.fyk.entity.Book;
import com.fyk.entity.User;
import com.fyk.mapper.UserMapper;
import com.fyk.service.BookService;
import com.fyk.service.ManageService;
import com.fyk.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author qazws
 * @Date 2022/8/19 9:03
 * @Version 1.0
 */

@RestController
public class ManageController {

    @Autowired
    private ManageService manageService;

    @Autowired
    private BookService bookService;

    @RequestMapping("/manage/{url}")
    public ResultUtils manage(@PathVariable String url, User user){
        switch (url){
            case "findManage":
                return manageService.findManage();
            case "updateManage":
                return manageService.updateManage(user);
        }
        return null;
    }


    @RequestMapping("/manageBook/{url}")
    public ResultUtils manageBook(@PathVariable String url, Book book){
        switch (url){
            case "manage-bookList":
                return bookService.selectAllBook(book);
            case "manage-insertBook":
                return bookService.insertBook(book);
            case "manage-findBook":
                return bookService.findBook(book);
            case "manage-updateBook":
                return bookService.updateBook(book);
            case "manage-deleteBook":
                return bookService.deleteBook(book);
            case "manage-delAllBook":
                return bookService.delAllBook(book);
        }
        return null;
    }

    @RequestMapping("/manageUser/{url}")
    public ResultUtils manageUser(@PathVariable String url,User user){
        switch (url){
            case "manage-userList":
                return manageService.userList(user);
            case "manage-findUser":
                return manageService.find0User(user);
            case "manage-updateUser":
                return manageService.updateUser(user);
            case "manage-addUser":
                return manageService.addUser(user);
            case "manage-deletedUser":
                return manageService.deletedUser(user);
            case "manage-deleteUserList":
                return manageService.deleteUserList(user);
            case "manage-find1User":
                return manageService.find1User(user);
            case "manage-deleteUser":
                return manageService.deleteUser(user);
            case "manage-returnUser":
                return manageService.returnUser(user);
            case "manage-delAllUser":
                return manageService.delAllUser(user);
            case "manage-returnAllUser":
                return manageService.returnAllUser(user);
        }
        return null;
    }
}
